// compile:
// run:
#include <unistd.h>

#include <fstream>
#include <iostream>
#include <sstream>
using namespace std;

void Test1() {
  cerr.tie(nullptr);
  cerr << "cerr";
  // cin 解绑 cout, 此时old值为&cout
  ostream* old = cin.tie(nullptr);

  cout << "cout";
  int x;
  cin >> x;
  sleep(4);
}
void Test2() {
  stringstream ss;
  ss << "12343254";
  cout << "ss.tellp()=" << ss.tellp() << endl;
  cout << "ss.tellg()=" << ss.tellg() << endl;
  char a[6] = "hello";
  ss.seekp(0);
  ss.write(a, 5);
  cout << "ss.tellp()=" << ss.tellp() << endl;
  cout << "ss.tellg()=" << ss.tellg() << endl;
  ss.seekg(3);
  ss.read(a, 5);
  cout << "ss.tellp()=" << ss.tellp() << endl;
  cout << "ss.tellg()=" << ss.tellg() << endl;
  cout << a << endl;
  cout << ss.str();
}
int main() {
  // Test1();
  Test2();
  return 0;
}
